/**
 * jgamebox
 *
 * outlook@China software studio
 * Copyright (c) 2008-2011. All Rights Reserved.
 * http://www.outlook.com
 */

package org.outlook.common.measure;

/**
 * function:
 * 
 * @author watson email: watson.wu@hotmail.com
 * @date 2011-5-29
 */
public class Position implements Cloneable {

	int x;
	int y;
	int z;

	public Position() {
		this(0,0,0);
	}

	public Position(int x, int y, int z) {
		super();
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getZ() {
		return z;
	}

	public void setZ(int z) {
		this.z = z;
	}

	@Override
	protected Object clone() {
		try {
			return super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static Position distance(Position pos1, Position pos2) {
		Position clone = (Position) pos1.clone();
		clone.setX(clone.getX()-pos2.getX());
		clone.setY(clone.getY()-pos2.getY());
		clone.setZ(clone.getZ()-pos2.getZ());
		return clone;
	}

	@Override
	public String toString() {
		return new StringBuilder().append("Position[").append(getX()).append(",").append(getY()).append(",").append(getZ()).append("]").toString();
	}

}
